<template>
  <el-dialog title="详细" :visible.sync="open" width="60%"  :before-close="cancel">
    <el-form  size="mini" label-position="right" :rules="rules"  label-width="8rem">
      <el-row >
        <el-col :span="11">
          <el-form-item label="订单号:" prop="id">
            <span>{{ order.id }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="商品名称:" prop="goodsName">
            <span>{{ order.goodsName }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="预定抢购时间:">
            <span>{{ parseTime(order.presetTime, '{y}-{m}-{d}') }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="京东账号:">
            <span>{{ order.jdAccount }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="用户cookie:">
<!--            <span>{{ order.cookie }}</span>-->
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="cookie登记时间:">
            <span>{{ parseTime(order.cookieRecordTime, '{y}-{m}-{d}') }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="咸鱼账号:">
            <span>{{ order.fishAccount }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="客户姓名:">
            <span>{{ order.customerName }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="收货地址:">
            <span>{{ order.address }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="电话:">
            <span>{{ order.phoneNumber }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="免息券类型:">
            <dict-tag
              :options="dict.type.mx_type"
              :value="order.mxType"
            >
            </dict-tag>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="订单状态:">
            <dict-tag
              :options="dict.type.order_status"
              :value="order.status"
            >
            </dict-tag>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="用户id:">
            <span>{{ order.createUserId }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="单件商品原价:">
            <span>{{ order.goodsOriginalPrice }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="单件商品现价:">
            <span>{{ order.goodsNowPrice }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="商品数量:">
            <span>{{ order.goodsAmount }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="订单总价:">
            <span>{{ order.orderPrice }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="返现:">
            <span>{{ order.cashback }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="订单实际收入:">
            <span>{{ order.realIncome }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="订单归属人id:">
            <dict-tag
              :options="dict.type.ower_user"
              :value="order.ownerUserId"
            >
            </dict-tag>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="用户登录状态:">
            <span>{{ order.loginStatus }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="创建者:">
            <span>{{ order.createBy }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="创建时间:">
            <span>{{ parseTime(order.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="11">

        </el-col>
      </el-row>
      <el-row >

        <el-col :span="11">
          <el-form-item label="备注:">
            <span>{{ order.remark }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item label="订单完成时间:">
            <span>{{ parseTime(order.completeTime, '{y}-{m}-{d}') }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <div v-show="isUserInfoNotEmpty"  >
        <el-row>
          <el-button style="padding: 3px 0" type="text">用户信息:</el-button>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="闲鱼名:">
              <span>{{ userInfo.nickName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="用户名:">
              <span>{{userInfo.userName}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="客户编号:">
              <span>{{userInfo.customerId}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="手机号:">
              <span>{{userInfo.phoneNum }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="地址">
              <span>{{userInfo.address}}</span>
            </el-form-item>
          </el-col>

        </el-row>
      </div>
      <div v-show="!isUserInfoNotEmpty">
          <el-row>
            <el-button style="padding: 3px 0" type="text">暂无用户信息</el-button>
          </el-row>
      </div>

    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancel">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getToken } from '@/utils/auth'
import { importJinFenData } from '@/api/mx/rebate'
import {getOrderDetail} from "@/api/mx/order";

export default {
  dicts:['login_status','order_status','mx_type','ower_user'],
  name: 'orderDetail',
  props:{
    //父页面的打开条件
    open:{
      default:false
    },
  },
  watch:{
    open(val){
      if (val) {
        this.userInfo = {}
      }
    }
  },
  computed: {
    isUserInfoNotEmpty() {
      // 判断 userInfo 是否为空对象
      return Object.keys(this.userInfo).length > 0;
    }
  },
  data(){
    return{
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      fileList:[],
      uploadUrl: process.env.VUE_APP_BASE_API + "/jd/rebate/order/importIdAndOrderExcel",
      accept:  ".xls, .xlsx",
      // 表单参数
      form: {
      },
      fileSize: '5M',
      // 表单校验
      rules: {

      },
      buttonLoading: false,
      order:{},//订单
      userInfo:{},//用户信息
    }
  },
  methods:{
    /**
     * 获取订单详细
     */
    getOrderDetail(id){
      getOrderDetail(id).then(res=>{
        if (res.code == 200) {
          this.order = res.data;
          if (res.data.sysCustomer) {
            this.userInfo = res.data.sysCustomer
          }

        }

      })
    },
    //关闭
    cancel() {
      this.order = {}
      this.order = {}
      this.$emit('close')
    },
  }
}
</script>
<style scoped>

</style>
